home *** CD-ROM | disk | FTP | other *** search
- ;---------------------------------------------------------
- ; This defines a 1-bit full-adder and an 8-bit adder built
- ; using the full-adder. The modules in this file can be
- ; used with other PLDASM files if an adder is ever needed.
- ;---------------------------------------------------------
- TITLE 8-bit adder
-
-
- ;---------------------------------------------------------
- ;*-- beginning of 1-bit adder module ---------------------
- ;---------------------------------------------------------
- DEFMOD fulladd( a, b, cin, sum, cout )
- CHIP fulladd Intel_arch
-
- PIN a ;* one of the bits to be added
- PIN b ;* the other bit to be added
- PIN cin ;* the carry input from the previous stage
- PIN sum ;* the 1-bit sum of a+b+c
- PIN cout ;* the carry output to the next stage
-
- T_TAB( a b cin >> sum cout )
- 0 0 0 : 0 0
- 0 1 0 : 1 0
- 1 0 0 : 1 0
- 1 1 0 : 0 1
- 0 0 1 : 1 0
- 0 1 1 : 0 1
- 1 0 1 : 0 1
- 1 1 1 : 1 1
- ENDMOD
- ;*-- end of 1-bit adder module ---------------------------
-
-
- ;---------------------------------------------------------
- ;*-- beginning of 8-bit adder module ---------------------
- ;---------------------------------------------------------
- DEFMOD add8( a[0:7], b[0:7], cin, sum[0:7], cout )
- CHIP add8 Intel_arch
-
- PIN a[0:7] ;* one of the 8-bit inputs to be added
- PIN b[0:7] ;* add this 8-bit input to the first
- PIN cin ;* carry input (for cascaded adders)
- PIN sum[0:7] ;* sum of a[0:7]+b[0:7]+cin
- PIN cout ;* carry output (for cascading adders)
- PIN cry[0:6] ;* pins for holding the carry bits
- ;* from the 1-bit adders
-
- MODULE fulladd( a=a0,b=b0,cin=cin, sum=sum0,cout=cry0)
- MODULE fulladd( a=a1,b=b1,cin=cry0, sum=sum1,cout=cry1)
- MODULE fulladd( a=a2,b=b2,cin=cry1, sum=sum2,cout=cry2)
- MODULE fulladd( a=a3,b=b3,cin=cry2, sum=sum3,cout=cry3)
- MODULE fulladd( a=a4,b=b4,cin=cry3, sum=sum4,cout=cry4)
- MODULE fulladd( a=a5,b=b5,cin=cry4, sum=sum5,cout=cry5)
- MODULE fulladd( a=a6,b=b6,cin=cry5, sum=sum6,cout=cry6)
- MODULE fulladd( a=a7,b=b7,cin=cry6, sum=sum7,cout=cout)
- ENDMOD
- ;*-- end of 8-bit adder module --------------------------
-